package com.ruoyi.web.controller.web;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.nongjt.domain.NjtUserPerfect;
import com.ruoyi.nongjt.service.INjtUserPerfectService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * 用户资料完善Controller(前端Web)
 * 
 * @author ruoyi
 * @date 2024-09-27
 */
@RestController
@RequestMapping("/web/userPerfect")
public class WebNjtUserPerfectController extends BaseController
{
    @Autowired
    private INjtUserPerfectService njtUserPerfectService;

    /**
     * 查询用户资料完善列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtUserPerfect njtUserPerfect)
    {
        startPage();
        List<NjtUserPerfect> list = njtUserPerfectService.selectNjtUserPerfectList(njtUserPerfect);
        return getDataTable(list);
    }

    /**
     * 导出用户资料完善列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:export')")
    @Log(title = "用户资料完善", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtUserPerfect njtUserPerfect)
    {
        List<NjtUserPerfect> list = njtUserPerfectService.selectNjtUserPerfectList(njtUserPerfect);
        ExcelUtil<NjtUserPerfect> util = new ExcelUtil<NjtUserPerfect>(NjtUserPerfect.class);
        util.exportExcel(response, list, "用户资料完善数据");
    }

    /**
     * 获取用户资料完善详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(njtUserPerfectService.selectNjtUserPerfectById(id));
    }

    /**
     * 新增用户资料完善
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:add')")
    @Log(title = "用户资料完善", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtUserPerfect njtUserPerfect)
    {
        return toAjax(njtUserPerfectService.insertNjtUserPerfect(njtUserPerfect));
    }

    /**
     * 修改用户资料完善
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:edit')")
    @Log(title = "用户资料完善", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtUserPerfect njtUserPerfect)
    {
        return toAjax(njtUserPerfectService.updateNjtUserPerfect(njtUserPerfect));
    }

    /**
     * 删除用户资料完善
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:remove')")
    @Log(title = "用户资料完善", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(njtUserPerfectService.deleteNjtUserPerfectByIds(ids));
    }

    /**
     * 审核用户资料
     */
    @PreAuthorize("@ss.hasPermi('nongjt:userPerfect:audit')")
    @Log(title = "用户资料完善", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody NjtUserPerfect njtUserPerfect)
    {
        return toAjax(njtUserPerfectService.updatePerfectStatus(njtUserPerfect));
    }
}